<?php 

//Luu giu trang thai loc
$v_receive_date_filter = "";
if(isset($_REQUEST['hdn_received_date_filter'])){
	$v_receive_date_filter = $_REQUEST['hdn_received_date_filter'];
} 
$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
if(isset($_REQUEST['hdn_recordtype_filter'])){
	$v_recordtype_filter = $_REQUEST['hdn_recordtype_filter'];
} 
//echo $v_recordtype_filter."---";exit;
$v_record_id = 0;
if(isset($_REQUEST['hdn_record_id'])){
	$v_record_id = intval($_REQUEST['hdn_record_id']);
}
$v_record_id_list = "";
if(isset($_REQUEST['hdn_record_id_list'])){
	$v_record_id_list = $_REQUEST['hdn_record_id_list'];
	$v_arrs_record_id=explode(",",$v_record_id_list);
}
if(isset($_REQUEST['hdn_worktype'])) {
	$v_worktype = $_REQUEST['hdn_worktype'];
}else{
	$v_worktype = "";
}
if(isset($_REQUEST['hdn_record_number_page'])&&$_REQUEST['hdn_record_number_page']!=""){
	$v_limit_row = $_REQUEST['hdn_record_number_page'];
} 

//DatCQ 14102008 Phan cong thu ly tai tiep nhan.
$v_handler_id = "";
if(isset($_REQUEST['hdn_handler'])){
	$v_handler_id = $_REQUEST['hdn_handler'];
	//echo $v_handler_id;
}
//End 14102008 Phan cong thu ly tai tiep nhan.

$v_current_status = $arr_record_status[2][0];
$v_status_of_handover = 1;
$v_staff_id = $_SESSION['staff_id'];

if(_is_sqlserver()){
	//CHUYEN_HS_TP_LDPD:chuyen thang len Can bo phe duyet
	//TRINH_LDLC_TP:trinh lanh dao phe duyet lan cuoi
	$sql_single_config="Exec Onegate_ConfigRecordtypeGetSingle ";
	$sql_single_config=$sql_single_config."'".$v_recordtype_filter."'";
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$arr_single_config = $ado_conn->GetRow($sql_single_config); 
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
	$v_c_system_conf=$arr_single_config['C_SYSTEM_CONFIG'];
	$v_dateProcess=getColumnRecordtypeSingle($v_recordtype_filter,'C_PROCESS_DATE');

//------------------------
	//Leav_begin_update:14/06/2008 
	//echo $v_worktype;
	
	//Leav_begin_update:11112008:
	//Tong so ngay thu ly cho ho so nay:A
	//echo "test:".$recordtype_single['C_PROCESS_DATE'];exit;
	
	$sql = "Exec Onegate_RecordMoveToHandoverUpdate ";
	$sql = $sql . " '" .  $v_record_id_list . "'";
	$sql = $sql . "," . $v_staff_id ;
	$sql = $sql . ",'" . _ddmmyyyy_to_yyyymmdd($v_receive_date_filter) . "'" ;
	$sql = $sql . ",'" . $v_worktype . "'";;
	$sql = $sql . "," . $_ISA_AUTOMATIC_UPDATE_WORK_LIST;
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	//echo $sql.'<br>'; exit;	
	$rs = $ado_conn->GetRow($sql); 
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
	//DatCQ 14102008 Phan cong thu ly tai tiep nhan.
	if (is_null($v_error) || $v_error == "")
	{
		if($v_handler_id!= 0 && $v_handler_id!=''){
			$sql = "Exec Onegate_RecordHandlerUpdate ";
			$sql = $sql . " '" .  $v_record_id_list . "'";
			$sql = $sql . "," . $v_staff_id ;
			$sql = $sql . ",'" . _ddmmyyyy_to_yyyymmdd($v_receive_date_filter) . "'" ;
			$sql = $sql . "," . $_ISA_AUTOMATIC_UPDATE_WORK_LIST;
			$sql = $sql . "," . $v_handler_id ;
			$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
			$rs = $ado_conn->GetRow($sql); 
		//echo $sql.'<br>'; 
		}
	}
	
}
sleep(0);
if (!is_null($v_error) && $v_error<>""){?>
	<script>
		alert("<?php echo $v_error; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<?php echo $v_goto_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?php
	exit;
}
?>
<form action="index.php" method="post" name="f_back">
	
	<?php //Leav_begin_update:14/06/2008 
	if($v_worktype=="NOP_THUE"){?>
	<input type="hidden" name="fuseaction" value="DISPLAY_ALL_RECORD_DA_NOP_THUE">
	<?php }elseif($v_worktype=="NOP_PHAT"){?>
	<input type="hidden" name="fuseaction" value="DISPLAY_ALL_RECORD_DA_NOP_PHAT">
	<?php }else{?>
	<input type="hidden" name="fuseaction" value="DISPLAY_ALL_RECORD">	
	<?php }//Leav_end_update:14/06/2008?>
	<input type="hidden" name="hdn_record_id" value="<?php echo $v_record_id;?>">
	<input type="hidden" name="hdn_recordtype_filter" value="<?php echo $v_recordtype_filter; ?>">
	<input type="hidden" name="hdn_received_date_filter" value="<?php echo $v_receive_date_filter; ?>">
	<input type="hidden" name="hdn_current_item_id" value="<?php echo $v_record_id;?>">
	<input type='hidden' name='hdn_record_number_page' value='<?php echo $v_limit_row;?>'>
</form>
<Script language="javascript">
	document.forms(0).submit();
</Script>